package com.example.lanouhn.bantangapp.activities.utils;


import com.example.lanouhn.bantangapp.activities.contants.DT_sun;
import com.example.lanouhn.bantangapp.activities.contants.TogUser;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 解析Json数据
 */
public class JsonUtils_TogUser {

    /**
     * @param json json字符串
     * @return 搜索用户分类
     */
    public static List<TogUser> getuserList(String json) {
        List<TogUser> list = new ArrayList<>();
        try {
            JSONObject jsonObject = new JSONObject(json);

            JSONArray jsonArray = jsonObject.getJSONArray("data");

            for (int i = 0; i < jsonArray.length(); i++) {
                JSONObject j = jsonArray.getJSONObject(i);


                TogUser m = new TogUser();
                m.setNickname(j.getString("nickname"));
                m.setPic(j.getString("avatar"));
                list.add(m);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}
